﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Printing.DataGridViewPrint;
using System.Drawing;

namespace QLZJFurnitureSCM.WinForm
{
    public class FooterPrintBlock : PrintBlock
    {
        Font font = new Font("Tahoma", 9, GraphicsUnit.Point);

        private string content = string.Empty;

        public FooterPrintBlock(string content)
        {
            this.content = content;
        }

        public override SizeF GetSize(Graphics g, DocumentMetrics metrics)
        {
            return g.MeasureString("Page X Of Y", font);
        }

        public void Draw(System.Drawing.Graphics g, string foot)
        {
            StringFormat format = new StringFormat();
            format.Trimming = StringTrimming.Word;
            format.FormatFlags = StringFormatFlags.NoWrap;
            //format.Alignment = StringAlignment.Far;
            format.Alignment = StringAlignment.Center;

            // as you can see below, we are using the codes param to know on which page we are for instance.
            /*
            g.DrawString(
                string.Format("数量 {0} 总价 {1}", "100", "20,102,011"),
                font,
                new SolidBrush(Color.Black),
                Rectangle,
                format);*/
            //不打印页, 打印送货人, 操作人.
            g.DrawString(
                string.Format(foot),
                font,
                new SolidBrush(Color.Black),
                Rectangle,
                format);
            /*
            g.DrawString(
                string.Format("Page {0} Of {1}", codes[CodeEnum.SheetNumber], codes[CodeEnum.SheetsCount]),
                font,
                new SolidBrush(Color.Black),
                Rectangle,
                format);*/
        }

        public override void Draw(Graphics g, Dictionary<CodeEnum, string> codes)
        {
            StringFormat format = new StringFormat();
            format.Trimming = StringTrimming.Word;
            format.FormatFlags = StringFormatFlags.NoWrap;
            //format.Alignment = StringAlignment.Far;
            format.Alignment = StringAlignment.Center;

            g.DrawString(
                string.Format(content),
                font,
                new SolidBrush(Color.Black),
                Rectangle,
                format);
        }
    }
}
